(function(t){if(t.BX.timer)return;var i=[],e=200,a=null,s=0;BX.timer=function(t,i){i=i||{};if(BX.type.isString(t)||BX.type.isElementNode(t))i.container=t;else if(typeof t=="object")i=t;if(!i.container)return false;var s=new BX.CTimer(i);BX.timer.start(s);if(null==a){a=setInterval(r,e);BX.garbage(BX.timer.clear)}return s};BX.timer.stop=function(t){i[t.TIMER_INDEX]=null};BX.timer.start=function(t){t.TIMER_INDEX=s;i[s++]=t};BX.timer.clock=function(t,i){return BX.timer({container:t,dt:i})};BX.timer.clear=function(){clearInterval(a);i=null};BX.timer.registerFormat=function(t,i){BX.CTimer.prototype.formatValueHandlers[t]=i};BX.timer.getHandler=function(t){return BX.CTimer.prototype.formatValueHandlers[t]};BX.CTimer=function(t,i){this.container=t.container;this.from=t.from?parseInt(t.from.valueOf()):null;this.to=t.to?parseInt(t.to.valueOf()):null;this.index=i;this.dt=parseInt(t.dt);if(isNaN(this.dt))this.dt=0;this.display=t.display||(BX.isAmPmMode()?"clock_am_pm":"clock");this.accuracy=t.accuracy||60;this.callback=this.from?this._callback_from:this.to?this._callback_to:this._callback;this.callback_finish=t.callback_finish;this.formatValue=this.formatValueHandlers.clock;this.bInited=false;BX.ready(BX.delegate(this.Init,this))};BX.CTimer.prototype.Init=function(){if(this.bInited)return;this.container=BX(this.container);this.container_value_fld=this.container.tagName.toUpperCase()=="INPUT"?"value":"innerHTML";if(this.container_value_fld=="value"&&(this.display=="clock"||this.display=="clock_am_pm")){if(this.display=="clock"){this.display="simple"}else if(this.display=="clock_am_pm"){this.display="simple_am_pm"}}this.formatValue=this.formatValueHandlers[this.display]?this.formatValueHandlers[this.display]:this.formatValueHandlers.clock;this.bInited=true};BX.CTimer.prototype.setFrom=function(t){if(!this.from)return;this.from=t};BX.CTimer.prototype.setTo=function(t){if(!this.to)return;this.to=t};BX.CTimer.prototype._callback=function(t){if(this.dt!==0)var t=new Date(t.valueOf()+this.dt);this.setValue(this.formatValue(t.getHours(),t.getMinutes(),t.getSeconds()))};BX.CTimer.prototype._callback_from=function(t){var i=(t.valueOf()-this.from.valueOf()+this.dt)/1e3;this.setValue(this.formatValue(parseInt(i/3600),parseInt(i%3600/60),parseInt(i%60)))};BX.CTimer.prototype._callback_to=function(t){var i=(this.to.valueOf()-t.valueOf())/1e3;if(i>0){this.setValue(this.formatValue(parseInt(i/3600),parseInt(i%3600/60),parseInt(i%60)))}else{this.Finish()}};BX.CTimer.prototype.formatValueHandlers={clock:function(t,i,e){var a='<span class="bx-timer-semicolon">:</span>';return BX.util.str_pad(t,2,"0","left")+a+(this.accuracy>=3600?"00":BX.util.str_pad(i,2,"0","left"))+(this.accuracy>=60?"":a+BX.util.str_pad(e,2,"0","left"))},clock_am_pm:function(t,i,e){var a="am";var s='<span class="bx-timer-semicolon">:</span>';if(t>12){t=t-12;a="pm"}else if(t==0){t=12;a="am"}else if(t==12){a="pm"}return t+s+(this.accuracy>=3600?"00":BX.util.str_pad(i,2,"0","left"))+(this.accuracy>=60?"":s+BX.util.str_pad(e,2,"0","left"))+" "+a},simple:function(t,i,e){return BX.util.str_pad(t,2,"0","left")+":"+(this.accuracy>=3600?"00":BX.util.str_pad(i,2,"0","left"))+(this.accuracy>=60?"":":"+BX.util.str_pad(e,2,"0","left"))},simple_am_pm:function(t,i,e){var a="am";if(t>12){t=t-12;a="pm"}else if(t==0){t=12;a="am"}else if(t==12){a="pm"}return t+":"+(this.accuracy>=3600?"00":BX.util.str_pad(i,2,"0","left"))+(this.accuracy>=60?"":":"+BX.util.str_pad(e,2,"0","left"))+" "+a},worktime:function(t,i,e){return t+BX.message("JS_CORE_H")+" "+(this.accuracy>=3600?"":i+BX.message("JS_CORE_M")+(this.accuracy>=60?"":" "+e+BX.message("JS_CORE_S")))},worktime_short:function(t,i,e){return BX.util.rtrim((t>0?t+BX.message("JS_CORE_H")+" ":"")+(i>0&&this.accuracy<3600?i+BX.message("JS_CORE_M")+" ":"")+(this.accuracy>=60?"":e>0?e+BX.message("JS_CORE_S"):""))}};BX.CTimer.prototype.setValue=function(t){if(this.bInited){if(t!=this._last_value)this.container[this.container_value_fld]=t;this._last_value=t}};BX.CTimer.prototype.Finish=function(){BX.timer.stop(this);if(this.callback_finish)this.callback_finish.apply(this);BX.cleanNode(this.container.parentNode)};function r(){var t=new Date;for(var e=0,a=s;e<a;e++){if(i[e]&&i[e].callback)i[e].callback.apply(i[e],[t])}t=null}})(window);
//# sourceMappingURL=core_timer.map.js